package sht.commons;

import java.sql.Timestamp;
import java.util.Date;

import org.hibernate.Query;

public class ParamUtil {
	public static void parseParam(Query query,String key,Object value) {
		if(value instanceof String) {
			query.setString(key, (String)value);
		}else if(value instanceof Integer) {
			query.setInteger(key, (Integer)value);
		}else if(value instanceof Boolean) {
			query.setBoolean(key, (Boolean)value);
		}else if(value instanceof Date) {
			query.setDate(key, (Date)value);
		}else if(value instanceof Double) {
			query.setDouble(key, (Double)value);
		}else if(value instanceof Float) {
			query.setFloat(key, (Float)value);
		}else if(value instanceof Long) {
			query.setLong(key, (Long)value);
		}else if(value instanceof Timestamp) {
			query.setTimestamp(key, (Timestamp)value);
		}else if(value instanceof Byte) {
			query.setByte(key, (byte)value);
		}else if(value instanceof Byte[]) {
			query.setBinary(key, (byte[])value);
		}
	}
}
